﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Madrigal.Lib
{
    public class _2DRender
    {
        VertexBuffer vbRect;
        VertexBuffer vbFillRect;
        VertexBuffer vbRoundRect;
        VertexBuffer vbFillTriangle;
        VertexBuffer vbTriangle;
        VertexBuffer vbLine;
        VertexBuffer vbPixel;

        GraphicsDevice graphicsDevice;
        Int32 dwTextColor;
        SpriteFont font;
        Point ptOrigin;
        Rectangle clipRect;

        public _2DRender() { }

        public Point GetViewportOrg() { return ptOrigin; }
	    public void SetViewportOrg(Point pt) { ptOrigin = pt; }
	    public void SetViewportOrg(int x,int y) { ptOrigin = new Point(x,y); }
	    public void SetViewport(Rectangle rect);
	    public void SetViewport(int nLeft,int nTop,int nRight,int nBottom);

	    public bool ResizeRectVB( Rectangle pRect, Int32 dwColorLT, Int32 dwColorRT, Int32 dwColorLB, Int32 dwColorRB, VertexBuffer vb );
	    public bool RenderRect  ( Rectangle rect, Int32 dwColorLT, Int32 dwColorRT, Int32 dwColorLB, Int32 dwColorRB );
	    public bool RenderRect  ( Rectangle rect, Int32 dwColor ) { return RenderRect( rect, dwColor, dwColor, dwColor, dwColor); }
	    public bool RenderResizeRect( Rectangle rect, int nThick );

        public bool ResizeFillRectVB(Rectangle pRect, Int32 dwColorLT, Int32 dwColorRT, Int32 dwColorLB, Int32 dwColorRB, VertexBuffer vb, Texture2D m_pTexture);
        public bool RenderFillRect(Rectangle rect, Int32 dwColorLT, Int32 dwColorRT, Int32 dwColorLB, Int32 dwColorRB, Texture2D m_pTexture);
        public bool RenderFillRect(Rectangle rect, Int32 dwColor, Texture2D m_pTexture) { return RenderFillRect(rect, dwColor, dwColor, dwColor, dwColor, m_pTexture); }

        public bool ResizeRoundRectVB(Rectangle pRect, Int32 dwColorLT, Int32 dwColorRT, Int32 dwColorLB, Int32 dwColorRB, VertexBuffer vb, Texture2D m_pTexture);
        public bool RenderRoundRect(Rectangle rect, Int32 dwColorLT, Int32 dwColorRT, Int32 dwColorLB, Int32 dwColorRB, Texture2D m_pTexture);
        public bool RenderRoundRect(Rectangle rect, Int32 dwColor, Texture2D m_pTexture) { return RenderRoundRect(rect, dwColor, dwColor, dwColor, dwColor, m_pTexture); }

        public bool RenderLine(Point pt1, Point pt2, Int32 dwColor1, Int32 dwColor2);
        public bool RenderLine(Point pt1, Point pt2, Int32 dwColor) { return RenderLine(pt1, pt2, dwColor, dwColor); }

        public bool RenderTriangle(Point pt1, Point pt2, Point pt3, Int32 dwColor1, Int32 dwColor2, Int32 dwColor3);
        public bool RenderTriangle(Point pt1, Point pt2, Point pt3, Int32 dwColor) { return RenderTriangle(pt1, pt2, pt3, dwColor, dwColor, dwColor); }

        public bool RenderFillTriangle(Point pt1, Point pt2, Point pt3, Int32 dwColor1, Int32 dwColor2, Int32 dwColor3);
        public bool RenderFillTriangle(Point pt1, Point pt2, Point pt3, Int32 dwColor) { return RenderFillTriangle(pt1, pt2, pt3, dwColor, dwColor, dwColor); }

        public bool RenderTextureEx( Point pt, Point pt2, Texture2D pTexture, Int32 dwBlendFactorAlhpa, float fScaleX , float fScaleY, bool bAnti);
	    public bool RenderTexture( Point pt, Texture2D pTexture, Int32 dwBlendFactorAlhpa, float fScaleX, float fScaleY );
	    public bool RenderTextureRotate( Point pt, Texture2D pTexture, Int32 dwBlendFactorAlhpa, float fScaleX , v fScaleY, float fRadian );

        public bool RenderTextureRotate(Point pt, Texture2D pTexture, Int32 dwBlendFactorAlhpa, float fRadian, bool bCenter, float fScaleX, float fScaleY);

        public bool RenderTexture2( Point pt, Texture2D pTexture, float fScaleX, float fScaleY, Color color);
	    public bool RenderTextureEx2( Point pt, CPoint pt2, Texture2D pTexture, Int32 dwBlendFactorAlhpa, float fScaleX , float fScaleY, Color color );
	    public bool RenderTextureColor( Point pt, Texture2D pTexture, float fScaleX , float fScaleY, Color color );
    		
	    public void SetTextColor( Int32 dwColor ) { m_dwTextColor = dwColor; }
	    public Int32 GetTextColor() { return m_dwTextColor; }
    }
}
